﻿
namespace KinonekoSoftware.Foundation.UI.Controls.Buttons
{
    public class TextButton : ForestButtonBase
    {
        public static readonly DependencyProperty IsOpenContextMenuProperty;

        static TextButton()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextButton), new FrameworkPropertyMetadata(typeof(TextButton)));
            IsOpenContextMenuProperty = DependencyProperty.Register(
                nameof(IsOpenContextMenu),
                typeof(bool),
                typeof(TextButton),
                new PropertyMetadata(Boxing.False));
        }

        protected override void OnClick()
        {
            if (ContextMenu is not null)
            {
                ContextMenu.PlacementTarget = this;
                ContextMenu.Placement = PlacementMode.Bottom;
                ContextMenu.IsOpen = true;
            }
            base.OnClick();
        }

        public bool IsOpenContextMenu
        {
            get => (bool)GetValue(IsOpenContextMenuProperty);
            set => SetValue(IsOpenContextMenuProperty, Boxing.Box(value));
        }

    }
}